

<link rel="stylesheet" th:href="@{/ui/css/amazeui.chosen.css}" />
<script th:src="@{/ui/js/amazeui.chosen.js}"></script>
<script th:src="@{/ui/js/region.js}"></script>

<div class="row-content am-cf">
	<div class="row">
		<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
			<div class="widget am-cf">
				<div class="widget-head am-cf">
					<div class="widget-title am-fl">编辑合伙人</div>
					<div class="widget-function am-fr">
						<a href="javascript:;" class="am-icon-cog"></a>
					</div>
				</div>
				<div class="widget-body am-fr">
					<form class="am-form tpl-form-line-form" id="agentForm" method="post">
						
						<div class="am-form-group">
							<label for="realName" class="am-u-sm-2 am-form-label">合伙人姓名:</label>
							<div class="am-u-sm-4">
								<input type="text"  class="tpl-form-input" readonly="readonly" th:value="${agent.realName}" required="required"/> 
							</div>
							<label for="mobile" class="am-u-sm-2 am-form-label">手机号:</label>
							<div class="am-u-sm-4">
								<input type="number"  class="tpl-form-input" readonly="readonly" th:value="${agent.mobile}" required="required"/> 
							</div>
						</div>
						
						<div class="am-form-group">
							<label for="idcard" class="am-u-sm-2 am-form-label">身份证:</label>
							<div class="am-u-sm-4">
								<input type="text"  class="tpl-form-input" readonly="readonly" th:value="${agent.idcard}"   required="required" /> 
							</div>
							<label for="bankId" class="am-u-sm-2 am-form-label">合伙人银行:</label>
							<div class="am-u-sm-4">
								<select id="bankId"  data-am-selected="{btnWidth: '40%', btnSize: 'sm'}" name="bankId" disabled="disabled" >
									<option value="">请选择银行</option>
									<option th:each="bank : ${banks}" 	     th:value="${bank.id}"    th:text="${bank.name}" th:selected="${bank.id== (agentBankCard != nul?agentBankCard.bankId:'')}"></option>
								</select> 
							</div>
						</div>
						<div class="am-form-group">
							<label for="cardNo" class="am-u-sm-2 am-form-label">合伙人银行卡号:</label>
							<div class="am-u-sm-4">
								<input type="number" id="cardNo" class="tpl-form-input" placeholder="合伙人银行卡号" th:value="${agentBankCard != null?agentBankCard.cardno:''}" readonly="readonly"  /> 
							</div>
							<label for="role" class="am-u-sm-2 am-form-label">等级:</label>
							<div class="am-u-sm-4">
								<select id="grade" data-am-selected="{searchBox: 1}"  style="display: none;" name="grade" required="required" disabled="disabled" >
									<option th:each="grade : ${grades}" 	     th:value="${grade.key}"    th:text="${grade.value}" th:selected="${grade.key==agent.grade}"></option>
								</select> 
							</div>
						</div>
						
						<div class="am-form-group">
							<label for="job" class="am-u-sm-2 am-form-label">职业:</label>
							<div class="am-u-sm-4">
								<select id="job" data-am-selected="{searchBox: 1}"  style="display: none;" name="job" required="required">
									<option th:each="job : ${jobs}"  th:value="${job.key}"    th:text="${job.value}" th:selected="${job.key==agentDetail.job}"></option>
								</select> 
							</div>
							
							<label for="workplace" class="am-u-sm-2 am-form-label">工作单位:</label>
							<div class="am-u-sm-4">
								<input type="text" id="desc" name="workplace" placeholder="请输入工作单位" th:value="${agentDetail.workplace}" />
							</div>
   					    </div>
   					    
   					    <div class="am-form-group">
							<label for="address" class="am-u-sm-2 am-form-label">合伙人家庭住址:</label>
							<div class="am-u-sm-4">
								<input type="text" id="address" name="address" th:value="${agentDetail.address}" placeholder="请输入合伙人家庭住址"/>
							</div>
							<label for="relativeName" class="am-u-sm-2 am-form-label">直系亲属:</label>
							<div class="am-u-sm-4">
								<input type="text" id="relativeName" name="relativeName" th:value="${agentDetail.relativeName}" placeholder="请输入直系亲属"/>
							</div>
   					    </div>
   					    <div class="am-form-group">
							<label for="relativePhone" class="am-u-sm-2 am-form-label">直系亲属电话:</label>
							<div class="am-u-sm-4">
								<input type="text" id="relativePhone" name="relativePhone" th:value="${agentDetail.relativePhone}" placeholder="请输入直系亲属电话"/>
							</div>
							<input type="hidden" class="am-u-sm-3" name="agentId" th:value="${agent.id}" />
							<input type="hidden" class="am-u-sm-3" name="agentDetailId" th:value="${agentDetail.id}" />
   					    </div>
   					    
   					   	<div class="am-form-group">
							<label for="province" class="am-u-sm-2 am-form-label">管辖区域:</label>
					        <select id="provinceId" name="provinceId" data-placeholder="请选择省"  th:value="${agentDetail.provinceId}"  class="province" style="width:12%" tabindex="7" >
					            <option value=""></option>
					            
					        </select>
					        <select data-placeholder="请选择市" class="city" id="cityId" name="cityId" style="width:12%" tabindex="7" th:value="${agentDetail.cityId}">
					            <option value=""></option>
					
					        </select>
					        <select data-placeholder="请选择区/县" class="area" id="countyId" name="countyId" style="width:12%" tabindex="7" th:value="${agentDetail.countyId}">
					            <option value=""></option>
					        </select>
					         <select data-placeholder="请选择乡/镇" class="town" id="townId" name="townId" style="width:12%" tabindex="7" th:value="${agentDetail.townId}">
					            <option value=""></option>
					        </select>
   					    </div>
   					    
   					    <div class="am-form-group" id="villageDiv">
   					  	 	<label for="village" class="am-u-sm-2 am-form-label">村:</label>
							<div class="am-u-sm-10">
								<input type="text" id="village" name="village" placeholder="请输入管辖行政村" th:value="${agentDetail.village}" />
							</div>
						</div>

						<div class="am-form-group">
							<div class="am-u-sm-10 am-u-sm-push-2">
								
								<button type="button" onclick="javascript:$('#agentForm').submit();"
									class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
										<button type="button" onclick="loadPage('agentManage/listUI')"
									class="am-btn am-btn-success tpl-btn-bg-color-success ">返回</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>

	</div>
	<script th:inline="javascript">
	<![CDATA[
		
	var checkParentMobile = true;
	
	var canSubmit = true;//表单重复提交控制 
	
	$(document).ready(function(){
		
		$('#job,#grade').selected();
		
		if($("#grade").val() != "10"){
			$("#villageDiv").hide();
		}
	});
		

	validateUserForm();
	function validateUserForm(){    
	    $('#agentForm').validate({
	        errorElement : 'span',
	        errorClass : 'am-icon-times',
	        focusInvalid : true,
	        onkeyup:false,
	        ignore : "",
	        rules : {
	        	
	        },
	        messages : {
	        	
	        },
	        submitHandler : function(form) {
	        	if(checkParentMobile){
	        		if(canSubmit){
	        			canSubmit = false;
	        			commit('agentForm', 'agentManage/save','agentManage/listUI');
	        		}
	        		
	        	}
	        }
	    });
	}
		]]>
	</script>